#pragma once
#include <string>

typedef void *(*fun_t)(void *);

class ThreadData
{
public:
    std::string _name;
    void* _args;
};

class Thread
{
public:
    Thread(int num, fun_t callback, void *args) : _func(callback)
    {
        char nameBuffer[64];
        snprintf(nameBuffer, sizeof(nameBuffer), "Thread-%d", num);
        _name = nameBuffer;

        _tdata._args=args;
        _tdata._name = _name;

    }

    void start()
    {
        pthread_create(&_tid, nullptr, _func, (void*)&_tdata);
    }
    void join()
    {
        pthread_join(_tid, nullptr);
    }
    std::string name()
    {
        return _name;
    }
    ~Thread() {}

private:
    pthread_t _tid;
    fun_t _func;
    ThreadData _tdata;
    std::string _name;
};